<?php
require_once('../includes/SmartyManager.class.php');
require_once('../includes/functions.inc.php');
require_once('../includes/exceptions/AppExceptions.class.php');
require_once('../includes/SpecialFileStateAccountant.class.php');
require_once('../includes/AllFileStateAccountant.class.php');

$smarty = SmartyManager::getSmarty();
//try{

if(isset($_GET['filename'])){
	$smarty->assign('filename', $_GET['filename']);

	defined("DEBUG")?$pre=getMicroTime():null;

	$account = new SpecialFileStateAccountant($_GET['filename']);
	$account->execute();
	$smarty->assign( array(
				'certificationNumber' 	=> 	$account->getCertificationNumber(),
				'certificationCodification' 		=> 	$account->getCertificationCodification(),
				'sequenceNumber' 		=> 	$account->getSequenceNumber(),
				'manufactory' 		=> 	$account->getManufactory(),
				'authenticationMark' 		=> 	$account->getAuthenticationMark(),
				'steelNumber' 		=> 	$account->getSteelNumber(),
				'size1' 		=> 	$account->getSize1(),
				'size2' 		=> 	$account->getSize2(),
				'size3' 		=> 	$account->getSize3(),
				'count'	=>	$account->getCount(),
				'unitWeight'		=>	$account->getUnitWeight(),
				'weight'	=>	$account->getWeight(),
				'orderNumber'		=>	$account->getOrderNumber(),
				'orderSubitemNumber'		=>	$account->getOrderSubitemNumber(),
				'unitPrice'		=>	$account->getUnitPrice(),
				'materialNumber'		=>  $account->getMaterialNumber(),
				'consignmentBatch'	=>  $account->getConsignmentBatch(),
				'sampleBatch'		=>  $account->getSampleBatch(),
				'facheNumber'	=>  $account->getFacheNumber(),
				'purchaseNumber'	=>  $account->getPurchaseNumber(),
				'shipmentDate'	=>  $account->getShipmentDate(),
				'month'	=>  $account->getMonth(),
				'vehicleNumber'	=>  $account->getVehicleNumber(),
				'consignee'	=>  $account->getConsignee(),
				'remark'	=>  $account->getRemark(),
				'stat'		=> $account->getStat()
		));
	if(defined("DEBUG")){
		$inteval = getMicroTime()-$pre;
		echo "a speacial file state Time:".$inteval.'<br />';
	}
	$smarty->display('fileStat.html');

}else{

	defined("DEBUG")?$pre=getMicroTime():null;

	$account = new AllFileStateAccountant(false);
	$account->execute();

	if(defined("DEBUG")){
		$inteval = getMicroTime()-$pre;
		echo "get all files'state Time:".$inteval.'<br />';
	}
	$smarty->assign('filename', $account->getFilename());
	$smarty->assign('uploadTime', $account->getUploadTime());
	$smarty->assign('count', $account->getDistinctCertificationNumberCount());
	$smarty->display('allFileStats.html');
}
//
//}catch(Exception $e){
//	$smarty->assign('errTitle', '出现错误');
//	$smarty->assign('errMsg', '数据库查询和运算时出现错误');
//	$smarty->display('error.html');
//}
?>